import Vue from 'vue'
import Router from 'vue-router'

import Layout from '@/components/Menu'
// import Server from '@/pages/List/components/server/Server'

Vue.use(Router)

const originalPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

// roles弃用
export const constantRoutes = [
  {
    path: '/404',
    component: resolve => require(['@/pages/error-page/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: resolve => require(['@/pages/error-page/401'], resolve),
    hidden: true
  },
  {
    path: '/null',
    component: resolve => require(['@/pages/error-page/null'], resolve),
    hidden: true
  },
  {
    path: '/',
    redirect: '/menu',
    name: 'Menu',
    component: Layout,
    children: [
      {
        path: '/menu',
        // component: resolve => require(['@/components/Command'], resolve),
        component: resolve => require(['@/pages/Home/Home'], resolve),
        meta: { title: '首页' }
      }
    ]
  },
  {
    path: '/testApi',
    name: 'TestApi',
    component: resolve => require(['@/pages/Home/testApi'], resolve),
    meta: { title: '命令验证' }
  },
  {
    path: '/login',
    name: 'Login',
    component: resolve => require(['@/components/Login'], resolve),
    meta: { title: '登录' }
  },
  {
    path: '/authLogin',
    name: 'authLogin',
    component: resolve => require(['@/pages/authLogin/AuthLogin'], resolve),
    meta: { title: '登录' }
  },
  {
    path: '/authMenu',
    name: 'authMenu',
    component: resolve => require(['@/pages/authLogin/AuthMenu'], resolve),
    meta: { title: '用户认证' }
  },
  {
    path: '/changePassword',
    name: 'changePassword',
    component: resolve => require(['@/pages/Home/ChangePassword'], resolve),
    meta: { title: '修改密码' }
  }
]
export const asyncRoutes = [
  {
    path: '/obj',
    name: 'Obj',
    component: Layout,
    meta: { roles: ['超级管理员', '配置管理员'] },
    children: [
      {
        path: '/obj/address',
        name: 'address',
        component: resolve => require(['@/pages/List/addr/Addr'], resolve),
        meta: { title: '地址', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/obj/addressGroup',
        name: 'AddrGroup',
        component: resolve => require(['@/pages/List/addr_group/AddrGroup'], resolve),
        meta: { title: '地址组', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/obj/responsible',
        name: 'responsible',
        component: resolve => require(['@/pages/List/responsible/Responsible'], resolve),
        meta: { title: '责任人', roles: ['超级管理员'] }
      },
      {
        path: '/obj/assetobject',
        name: 'assetobject',
        component: resolve => require(['@/pages/List/assetobject/Assetobject'], resolve),
        meta: { title: '资产对象', roles: ['超级管理员'] }
      },
      {
        path: '/obj/assetgroup',
        name: 'assetgroup',
        component: resolve => require(['@/pages/List/assetgroup/Assetgroup'], resolve),
        meta: { title: '资产组', roles: ['超级管理员'] }
      },
      {
        path: '/obj/service',
        name: 'Server',
        component: resolve => require(['@/pages/List/server/Server'], resolve),
        meta: { title: '服务', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/obj/app',
        name: 'App',
        component: resolve => require(['@/pages/List/app/App'], resolve),
        meta: { title: '应用', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/obj/time',
        name: 'Time',
        component: resolve => require(['@/pages/List/time/Time'], resolve),
        meta: { title: '时间', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/obj/safeArea',
        name: 'safeArea',
        component: resolve => require(['@/pages/List/safe/Safe'], resolve),
        meta: { title: '安全区域', roles: ['超级管理员', '配置管理员'] }
      }
    ]
  },
  {
    path: '/network',
    name: 'Network',
    component: Layout,
    meta: { roles: ['超级管理员', '配置管理员'] },
    children: [
      {
        path: '/network/physical/interface',
        name: 'Physical',
        component: resolve => require(['@/pages/network/api/physical/Physical'], resolve),
        meta: { title: '物理接口', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/Link/interface',
        name: 'Interface',
        component: resolve => require(['@/pages/network/api/link/Link'], resolve),
        meta: { title: '接口联动', roles: ['超级管理员'] }
      },
      {
        path: '/network/bond/interface',
        name: 'bond',
        component: resolve => require(['@/pages/network/api/bond/Bond'], resolve),
        meta: { title: '聚合接口', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/virtual/interface',
        name: 'Virtual',
        component: resolve => require(['@/pages/network/api/virtual/Virtual'], resolve),
        meta: { title: 'VLAN', roles: ['超级管理员'] }
        // meta: { title: '虚拟接口', roles: ['超级管理员'] }
      },
      {
        path: '/network/sub/interface',
        name: 'Sub',
        component: resolve => require(['@/pages/network/api/subInterface/subInterface'], resolve),
        meta: { title: '子接口', roles: ['超级管理员'] }
      },
      {
        path: '/network/vlan',
        name: 'vlan',
        component: resolve => require(['@/pages/network/api/vlan/vlan'], resolve),
        meta: { title: 'VLAN', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/dynamicRoute',
        name: 'DynamicRoute',
        component: resolve => require(['@/pages/network/route/dynamicRoute/DynamicRoute'], resolve),
        meta: { title: '动态路由', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/staticRoute',
        name: 'StaticRoute',
        component: resolve => require(['@/pages/network/route/staticRoute/StaticRoute'], resolve),
        meta: { title: '静态路由', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/radvd',
        name: 'radvd',
        component: resolve => require(['@/pages/network/route/radvd/Radvd'], resolve),
        meta: { title: 'RADVD', roles: ['超级管理员'] }
      },
      {
        path: '/network/policyRoute',
        name: 'PolicyRoute',
        component: resolve => require(['@/pages/network/route/policyRoute/PolicyRoute'], resolve),
        meta: { title: '策略路由', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/multicast',
        name: 'Multicast',
        component: resolve => require(['@/pages/network/route/multicast/Multicast'], resolve),
        meta: { title: '组播组', roles: ['超级管理员'] }
      },
      {
        path: '/network/multicastroute',
        name: 'Multicastroute',
        component: resolve => require(['@/pages/network/route/multicastroute/Multicastroute'], resolve),
        meta: { title: '组播路由', roles: ['超级管理员'] }
      },
      {
        path: '/network/ipv6/ipv6over4',
        name: '6over4',
        component: resolve => require(['@/pages/network/tunnel/ipv6over4/ipv6over4'], resolve),
        meta: { title: '6over4隧道', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/ipv6/ipv6to4',
        name: '6to4',
        component: resolve => require(['@/pages/network/tunnel/ipv6to4/ipv6to4'], resolve),
        meta: { title: '6to4隧道', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/ipv6/isatap',
        name: 'isatap',
        component: resolve => require(['@/pages/network/tunnel/isatap/isatap'], resolve),
        meta: { title: 'isatap隧道', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/vpn',
        name: 'Vpn',
        component: resolve => require(['@/pages/network/ipsecvpn/ipsecvpn'], resolve),
        meta: { title: 'IPSec VPN', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/nat/snat',
        name: 'SNAT',
        component: resolve => require(['@/pages/network/address/snat/Snat'], resolve),
        meta: { title: 'SNAT', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/nat/dnat',
        name: 'DNAT',
        component: resolve => require(['@/pages/network/address/dnat/Dnat'], resolve),
        meta: { title: 'DNAT', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/nat64',
        name: 'nat64',
        component: resolve => require(['@/pages/network/address/nat64/Nat64'], resolve),
        meta: { title: 'NAT64', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/nat46',
        name: 'nat46',
        component: resolve => require(['@/pages/network/address/nat46/Nat46'], resolve),
        meta: { title: 'NAT46', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/linkShow',
        name: 'linkShow',
        component: resolve => require(['@/pages/network/link/show/Show'], resolve),
        meta: { title: '连接查看', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/linkConfig',
        name: 'linkConfig',
        component: resolve => require(['@/pages/network/link/config/Config'], resolve),
        meta: { title: '参数设置', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/interfaceFlow',
        name: 'interfaceFlow',
        component: resolve => require(['@/pages/network/flow/interfaceFlow/InterfaceFlow'], resolve),
        meta: { title: '接口流量', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/flow',
        name: 'flow',
        component: resolve => require(['@/pages/network/flow/flow/Flow'], resolve),
        meta: { title: '策略流量', roles: ['超级管理员'] }
      },
      {
        path: '/network/mac/arp',
        name: 'arp',
        component: resolve => require(['@/pages/network/mac/arp/Arp'], resolve),
        meta: { title: 'arp表', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/mac/np',
        name: 'neighbor',
        component: resolve => require(['@/pages/network/mac/neighbor/Neighbor'], resolve),
        meta: { title: '邻居表', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/bypass',
        name: 'bypass',
        component: resolve => require(['@/pages/network/highAvailability/bypass/Bypass'], resolve),
        meta: { title: 'bypass', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/hotMachine',
        name: 'hotMachine',
        component: resolve => require(['@/pages/network/highAvailability/hotMachine/HotMachine'], resolve),
        meta: { title: '双机热备', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/qos',
        name: 'qos',
        component: resolve => require(['@/pages/network/bandwidth/Bandwidth'], resolve),
        meta: { title: '带宽管理', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/network/l2tp/l2tp',
        name: 'l2tp',
        component: resolve => require(['@/pages/network/L2TP/L2TP-PPTP/L2TP-PPTP'], resolve),
        meta: { title: 'L2TP/PPTP', roles: ['超级管理员'] }
      },
      {
        path: '/network/l2tp/tunnel',
        name: 'tunnel',
        component: resolve => require(['@/pages/network/L2TP/tunnel/Tunnel'], resolve),
        meta: { title: '隧道信息列表', roles: ['超级管理员'] }
      },
      {
        path: '/network/hosts',
        name: 'hosts',
        component: resolve => require(['@/pages/network/dnsHosts/hosts/Hosts'], resolve),
        meta: { title: 'Hosts配置', roles: ['超级管理员'] }
      },
      {
        path: '/network/dns',
        name: 'dns',
        component: resolve => require(['@/pages/network/dnsHosts/dns/Dns'], resolve),
        meta: { title: 'DNS配置', roles: ['超级管理员'] }
      }
    ]
  },
  {
    path: '/safe',
    name: 'Safe',
    component: Layout,
    meta: { roles: ['超级管理员', '配置管理员'] },
    children: [
      {
        path: '/safe/access',
        name: 'Strategy',
        component: resolve => require(['@/pages/Safe/access/strategy/Strategy'], resolve),
        meta: { title: '策略管理', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/assist',
        name: 'safeAssist',
        component: resolve => require(['@/pages/Safe/access/auxiliary/Auxiliary'], resolve),
        meta: { title: '辅助配置', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/template',
        name: 'safeTemplate',
        component: resolve => require(['@/pages/Safe/access/template/Template'], resolve),
        meta: { title: '模板配置', roles: ['超级管理员'] }
      },
      {
        path: '/safe/localAccess',
        name: 'Protect',
        component: resolve => require(['@/pages/Safe/access/protect/Protect'], resolve),
        meta: { title: '自身防护', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/analysis',
        name: 'Analysis',
        component: resolve => require(['@/pages/Safe/access/analysis/Analysis'], resolve),
        meta: { title: '工程解析', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/alg',
        name: 'Alg',
        component: resolve => require(['@/pages/Safe/alg/alg'], resolve),
        meta: { title: 'ALG', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/bind',
        name: 'bind',
        component: resolve => require(['@/pages/Safe/bind/Bind'], resolve),
        meta: { title: 'IP/MAC 绑定', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/connect',
        name: 'connect',
        component: resolve => require(['@/pages/Safe/connect/Connect'], resolve),
        meta: { title: '连接控制', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/ddos',
        name: 'ddos',
        component: resolve => require(['@/pages/Safe/ddos/Ddos'], resolve),
        meta: { title: 'FLOOD攻击防御', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/attackDefense',
        name: 'attackDefense',
        component: resolve => require(['@/pages/Safe/attackDefense/AttackDefense'], resolve),
        meta: { title: '异常报文攻击防御', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/ips',
        name: 'ips',
        component: resolve => require(['@/pages/Safe/ips/Ips'], resolve),
        meta: { title: '入侵防御', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/avDefend',
        name: 'av',
        component: resolve => require(['@/pages/Safe/av/Av'], resolve),
        meta: { title: '病毒过滤', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/url',
        name: 'url',
        component: resolve => require(['@/pages/Safe/url/Url'], resolve),
        meta: { title: 'URL类', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/urlPolicy',
        name: 'urlPolicy',
        component: resolve => require(['@/pages/Safe/urlPolicy/UrlPolicy'], resolve),
        meta: { title: 'URL策略', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/whiteList',
        name: 'whiteList',
        component: resolve => require(['@/pages/Safe/depth/white/WhiteList'], resolve),
        meta: { title: '白名单过滤', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/blackList',
        name: 'blackList',
        component: resolve => require(['@/pages/Safe/depth/black/BlackTab'], resolve),
        meta: { title: '黑名单过滤', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/contentFilter',
        name: 'contentList',
        component: resolve => require(['@/pages/Safe/depth/analysis/AnalysisList'], resolve),
        meta: { title: '协议分析', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/dynamicBlack',
        name: 'dynamicBlacklist',
        component: resolve => require(['@/pages/Safe/blacklist/dynamicBlacklist/DynamicBlacklist'], resolve),
        meta: { title: '动态黑名单', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/staticBlack',
        name: 'staticBlacklist',
        component: resolve => require(['@/pages/Safe/blacklist/staticBlacklist/StaticBlacklist'], resolve),
        meta: { title: '静态黑名单', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/learnConfig',
        name: 'learnConfig',
        component: resolve => require(['@/pages/Safe/intellect/learnConfig/LearnConfig'], resolve),
        meta: { title: '自学习配置', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/learnStatistics',
        name: 'learnStatistics',
        component: resolve => require(['@/pages/Safe/intellect/statistics/Statistics'], resolve),
        meta: { title: '自学习统计', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/server',
        name: 'server',
        component: resolve => require(['@/pages/Safe/intellect/server/Server'], resolve),
        meta: { title: '会话自学习列表', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/safe/industry',
        name: 'industry',
        component: resolve => require(['@/pages/Safe/intellect/industry/Industry'], resolve),
        meta: { title: '工业协议自学习列表', roles: ['超级管理员', '配置管理员'] }
      }
    ]
  },
  {
    path: '/system',
    name: 'system',
    component: Layout,
    meta: { roles: ['超级管理员', '审计管理员', '配置管理员', '系统管理员'] },
    children: [
      {
        path: '/system/configManager',
        name: 'ConfigManager',
        component: resolve => require(['@/pages/system/configManager/ConfigManager'], resolve),
        meta: { title: '配置管理', roles: ['超级管理员', '系统管理员'] }
      },
      {
        path: '/system/autoBackup',
        name: 'AutoBackup',
        component: resolve => require(['@/pages/system/autoBackup/AutoBackup'], resolve),
        meta: { title: '自动备份', roles: ['超级管理员', '系统管理员'] }
      },
      {
        path: '/system/config',
        name: 'Basic',
        component: resolve => require(['@/pages/system/basic/Basic'], resolve),
        meta: { title: '基本配置', roles: ['超级管理员', '系统管理员'] }
      },
      {
        path: '/system/log/syslogConfig',
        name: 'SyslogConfig',
        component: resolve => require(['@/pages/system/log/syslogConfig/SyslogConfig'], resolve),
        meta: { title: '日志配置', roles: ['超级管理员', '系统管理员'] }
      },
      {
        path: '/system/log/remoteSyslogConfig',
        name: 'RemoteSyslogConfig',
        component: resolve => require(['@/pages/system/log/remoteSyslogConfig/RemoteSyslogConfig'], resolve),
        meta: { title: '服务器日志配置', roles: ['超级管理员', '系统管理员'] }
      },
      {
        path: '/system/log/kafkaLogConfig',
        name: 'kafkaLogConfig',
        component: resolve => require(['@/pages/system/log/kafkaLogConfig/KafkaLogConfig'], resolve),
        meta: { title: 'kafka数据上报', roles: ['超级管理员', '系统管理员'] }
      },
      {
        path: '/system/log/managelog',
        name: 'managelog',
        component: resolve => require(['@/pages/system/log/managelog/Managelog'], resolve),
        meta: { title: '管理日志', roles: ['审计管理员'] }
      },
      {
        path: '/system/log/datalog',
        name: 'datalog',
        component: resolve => require(['@/pages/system/log/datalog/Datalog'], resolve),
        meta: { title: '数据日志', roles: ['审计管理员'] }
      },
      {
        path: '/system/log/logRecord',
        name: 'logRecord',
        component: resolve => require(['@/pages/system/log/datalog/logRecord/LogRecord'], resolve),
        meta: { title: '日志记录', roles: ['审计管理员'] }
      },
      {
        path: '/system/log/logSearch',
        name: 'logSearch',
        component: resolve => require(['@/pages/system/log/datalog/logSearch/LogSearch'], resolve),
        meta: { title: '日志查询', roles: ['审计管理员'] }
      },
      {
        path: '/system/log/logExport',
        name: 'logExport',
        component: resolve => require(['@/pages/system/log/datalog/logExport/LogExport'], resolve),
        meta: { title: '日志导出', roles: ['审计管理员'] }
      },
      {
        path: '/system/log/report',
        name: 'report',
        component: resolve => require(['@/pages/system/logReport/syslogReport/SyslogReport'], resolve),
        meta: { title: '日志报表', roles: ['审计管理员'] }
      },
      {
        path: '/system/log/diyReport',
        name: 'diyReport',
        component: resolve => require(['@/pages/system/logReport/diyReport/DiyReport'], resolve),
        meta: { title: '定制日志报表任务', roles: ['审计管理员'] }
      },
      {
        path: '/system/log/downloadReport',
        name: 'downloadReport',
        component: resolve => require(['@/pages/system/logReport/downloadReport/DownloadReport'], resolve),
        meta: { title: '日志报表下载', roles: ['审计管理员'] }
      },
      {
        path: '/system/log/oldmanagelog',
        name: 'oldmanagelog',
        component: resolve => require(['@/pages/system/oldLog/oldManageLog/OldManageLog'], resolve),
        meta: { title: '管理日志', roles: ['审计管理员'] }
      },
      {
        path: '/system/log/olddatalog',
        name: 'olddatalog',
        component: resolve => require(['@/pages/system/oldLog/oldLogSearch/OldLogSearch'], resolve),
        meta: { title: '数据日志', roles: ['审计管理员'] }
      },
      {
        path: '/system/log/temple',
        name: 'temple',
        component: resolve => require(['@/pages/system/logReport/templeReport/TempleReport'], resolve),
        meta: { title: '自定义报表模板', roles: ['审计管理员'] }
      },
      {
        path: '/system/log/reportSetting',
        name: 'reportSetting',
        component: resolve => require(['@/pages/system/logReport/reportSetting/ReportSetting'], resolve),
        meta: { title: '报表任务保存配置', roles: ['审计管理员'] }
      },
      {
        path: '/system/adminConfig/adminConfig',
        name: 'AdminConfig',
        component: resolve => require(['@/pages/system/adminConfig/adminConfig/AdminConfig'], resolve),
        meta: { title: '管理员管理', roles: ['超级管理员', '系统管理员'] }
      },
      {
        path: '/system/adminConfig/loginConfig',
        name: 'loginConfig',
        component: resolve => require(['@/pages/system/adminConfig/loginConfig/LoginConfig'], resolve),
        meta: { title: '管理员配置', roles: ['超级管理员', '系统管理员'] }
      },
      {
        path: '/system/version',
        name: 'version',
        component: resolve => require(['@/pages/system/upgrade/version/Version'], resolve),
        meta: { title: '版本信息', roles: ['超级管理员', '系统管理员'] }
      },
      {
        path: '/system/upgrade',
        name: 'upgrade',
        component: resolve => require(['@/pages/system/upgrade/upgrade/Upgrade'], resolve),
        meta: { title: '软件升级', roles: ['超级管理员', '系统管理员'] }
      },
      {
        path: '/system/systemUpgrade',
        name: 'upgrade',
        component: resolve => require(['@/pages/system/upgrade/systemUpgrade/SystemUpgrade'], resolve),
        meta: { title: '操作系统升级', roles: ['超级管理员', '系统管理员'] }
      },
      {
        path: '/system/dev',
        name: 'dev',
        component: resolve => require(['@/pages/system/dev/Dev'], resolve),
        meta: { title: '设备管理', roles: ['超级管理员', '系统管理员'] }
      },
      {
        path: '/system/snmp',
        name: 'snmp',
        component: resolve => require(['@/pages/system/snmp/index'], resolve),
        meta: { title: 'snmp', roles: ['超级管理员', '系统管理员'] }
      },
      {
        path: '/system/runMode',
        name: 'runMode',
        component: resolve => require(['@/pages/system/runMode/RunMode'], resolve),
        meta: { title: '运行模式', roles: ['超级管理员', '配置管理员', '系统管理员'] }
      },
      {
        path: '/system/ping',
        name: 'sysPing',
        component: resolve => require(['@/pages/system/debug/ping/Ping'], resolve),
        meta: { title: '连通性测试', roles: ['超级管理员', '配置管理员', '系统管理员'] }
      },
      {
        path: '/system/capture',
        name: 'capture',
        component: resolve => require(['@/pages/system/debug/capture/Capture'], resolve),
        meta: { title: '抓包', roles: ['超级管理员', '配置管理员', '系统管理员'] }
      },
      {
        path: '/system/debugInformation',
        name: 'debugInformation',
        component: resolve => require(['@/pages/system/debug/debugInformation/DebugInformation'], resolve),
        meta: { title: '调试信息', roles: ['超级管理员', '配置管理员', '系统管理员'] }
      },
      {
        path: '/system/alarm/alarmConfig',
        name: 'alarmConfig',
        component: resolve => require(['@/pages/system/alarm/config/AlarmConfig'], resolve),
        meta: { title: '告警配置', roles: ['超级管理员', '配置管理员', '系统管理员'] }
      },
      {
        path: '/system/alarm/alarmStrategy',
        name: 'alarmStrategy',
        component: resolve => require(['@/pages/system/alarm/strategy/AlarmStrategy'], resolve),
        meta: { title: '告警策略', roles: ['超级管理员', '配置管理员', '系统管理员'] }
      }
    ]
  },
  {
    path: '/user',
    name: 'User',
    component: Layout,
    meta: { roles: ['超级管理员', '配置管理员'] },
    children: [
      {
        path: '/user/online',
        name: 'online',
        component: resolve => require(['@/pages/user/online/Online'], resolve),
        meta: { title: '在线用户', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/user/user',
        name: 'users',
        component: resolve => require(['@/pages/user/user/user'], resolve),
        meta: { title: '用户管理', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/user/portal',
        name: 'portal',
        component: resolve => require(['@/pages/user/portal/Portal'], resolve),
        meta: { title: '门户配置', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/user/server',
        name: 'userServer',
        component: resolve => require(['@/pages/user/server/Server'], resolve),
        meta: { title: '认证服务器', roles: ['超级管理员', '配置管理员'] }
      },
      {
        path: '/user/menu',
        name: 'userMenu',
        component: resolve => require(['@/pages/user/userMenu/UserMenu'], resolve),
        meta: { title: '角色菜单管理', roles: ['超级管理员'] }
      }
    ]
  },
  { path: '/:pathMatch(.*)*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter () {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
